<?php /* SVN: $Id: admin_view.ctp 52564 2011-05-04 10:33:57Z aravindan_111act10 $ */ ?>
	<?php 
		if(!empty($this->params['isAjax'])):
			echo $this->element('flash_message');
		endif;
	?>
	<?php if(empty($this->params['isAjax']) && empty($this->params['named']['stat'])): ?>
    <?php 
		if(!empty($this->params['named']['city_slug'])):
			$url= array(
				'controller' => 'advertisers',
				'action' => 'index',
				'city_slug' => $this->params['named']['city_slug'],
			);
		else:
			$url= array(
				'controller' => 'advertisers',
				'action' => 'index',
			);			
		endif;
	?>
	<div class="js-tabs">
        <ul class="clearfix">
            <li><?php echo $html->link(sprintf(__l('All (%s)'),$advertisercount), $url,array('title' => __l('All')));?></li>           
       </ul>       
    </div>
    <?php else: ?>
		<div class="js-response js-responses">
         	<div class="js-search-responses">
            <h2><?php echo $pageTitle; ?></h2>
                <?php echo $form->create('Advertiser', array('type' => 'post', 'class' => 'normal search-form clearfix js-ajax-form {"container" : "js-search-responses"}', 'action'=>'index')); ?>
               
                    <?php echo $form->input('q', array('label' => __l('Keyword'))); ?>
                    <?php echo $form->input('main_filter_id', array('type' => 'hidden', 'value' => !empty($this->params['named']['main_filter_id'])? $this->params['named']['main_filter_id']:'')); ?>
                    <?php echo $form->input('filter_id', array('type' => 'hidden', 'value' => !empty($this->params['named']['filter_id'])?$this->params['named']['filter_id']:'')); ?>
                    <?php echo $form->input('tab_check', array('type' => 'hidden', 'value' => '1')); ?>             
                    <?php echo $form->submit(__l('Search'),array('name' => "data['Advertiser']['search']"));?>
                  
                <?php echo $form->end(); ?>
                
                   <div class="clearfix add-block1">
	        	<?php if(empty($this->params['named']['from_more_actions'])): ?>             
                    <?php echo $html->link(__l('Add'), array('controller' => 'Advertisers', 'action' => 'add'), array('class' => 'add','title'=>__l('Add'))); ?>
                <?php endif; ?>
	              </div>
                   
                <?php echo $form->create('Advertiser' , array('class' => 'normal','action' => 'update'));  ?>
                <?php echo $form->input('r', array('type' => 'hidden', 'value' => $this->params['url']['url'])); ?>
	        	<?php echo $this->element('paging_counter'); ?>	            
                <div class="overflow-block">
                <table class="list">
                    <tr>
                        <th><?php echo __l('Select'); ?></th>
                        <th><div class="js-pagination"><?php echo $paginator->sort(__l('Name'), 'Advertiser.name'); ?></div></th>
                        <th><div class="js-pagination"><?php echo $paginator->sort(__l('View'), 'Advertiser.view'); ?></div></th>
                        <th><div class="js-pagination"><?php echo $paginator->sort(__l('Click'), 'Advertiser.click'); ?></div></th>  
                        <th><div class="js-pagination"><?php echo $paginator->sort(__l('Position'), 'Advertiser.position'); ?></div></th>  
                        <th><div class="js-pagination"><?php echo $paginator->sort(__l('City'), 'Advertiser.city'); ?></div></th>  
                        <th><div class="js-pagination"><?php echo $paginator->sort(__l('Create date'), 'Advertiser.create_time'); ?></div></th>  
                        <th><div class="js-pagination"><?php echo $paginator->sort(__l('End date'), 'Advertiser.end_date'); ?></div></th>  
                    </tr>
					          <?php
                if (!empty($advertisers)):
                $i = 0;
                foreach ($advertisers as $advertiser):
                    $class = null;
                    if ($i++ % 2 == 0):
                        $class = ' class="altrow"';
                    endif;
                ?>
                    <tr<?php echo $class;?>>
                        <td>
                            <div class="actions-block">
                                <div class="actions round-5-left cities-action-block">
                                <span><?php echo $html->link(__l('Edit'), array('controller' => 'advertisers', 'action'=>'edit', $advertiser['Advertiser']['id']), array('class' => 'edit js-edit', 'title' => __l('Edit')));?></span>
                                <span><?php echo $html->link(__l('Delete'), array('action'=>'delete', $advertiser['Advertiser']['id']), array('class' => 'delete js-delete', 'title' => __l('Delete')));?></span>                          
                                </div>
                            </div>
                        <?php echo $form->input('User.'.$advertiser['Advertiser']['id'].'.id', array('type' => 'checkbox', 'id' => "admin_checkbox_".$advertiser['Advertiser']['id'], 'label' => false, 'class' => $status_class.' js-checkbox-list'));?>
                        </td>
                        <td class="dl"><?php echo $html->cText($advertiser['Advertiser']['name']);?></td>
                        <td class="dc"><?php echo $html->cText($advertiser['Advertiser']['view'])?></td>
                        <td class="dc"><?php echo $html->cText($advertiser['Advertiser']['click'])?></td>
                        <td class="dc"><?php echo Advertiser::positions($advertiser['Advertiser']['position'])?></td>
                        <td class="dl">
                        <?php
                            if(!empty($advertiser['City']))
                            {
                                $cities_list =array();
        						foreach($advertiser['City'] as $city_sub):
        							$cities_list[] =  $html->link($city_sub['name'], array('controller' => 'advertisers', 'action'=>'index', 'city_slug' => $city_sub['slug']),array('title' => sprintf(__l('%s'),$city_sub['name'])));
        						endforeach;
        						echo implode(', ', $cities_list);
                            }else
                            {
                                echo 'all';
                            }
    						
    					?>
                    </td>
                        <td class="dc"><?php echo $html->cDateTime($advertiser['Advertiser']['created'])?></td>
                        <td class="dc"><?php echo $html->cDateTime($advertiser['Advertiser']['end_date'])?></td>
                    </tr>
                <?php
                    endforeach;
                else:
                ?>
                    <tr>
                        <td colspan="17" class="notice"><?php echo __l('No advertisers available');?></td>
                    </tr>
                <?php
                endif;
                ?>
                </table>
                </div>
                <?php if (!empty($advertisers)):?>
                      <div class="admin-select-block">
                      <?php
                      if(!empty($this->params['named']['filter_id'])) { ?>
                        <div>
                        	<?php if(!empty($moreActions)): ?>
								<?php echo __l('Select:'); ?>
                                <?php echo $html->link(__l('All'), '#', array('class' => 'js-admin-select-all', 'title' => __l('All'))); ?>
                                <?php echo $html->link(__l('None'), '#', array('class' => 'js-admin-select-none', 'title' => __l('None'))); ?>
                            <?php endif; ?>
                        </div>
                       <?php } ?>
                        <div class="admin-checkbox-button"><?php 
                            if(!empty($moreActions)):
                                echo $form->input('more_action_id', array('class' => 'js-admin-index-autosubmit', 'label' => false, 'empty' => __l('-- More actions --')));
                            endif;
                             ?></div>
                        <div class="hide"> <?php echo $form->submit(__l('Submit'));  ?> </div>
                      </div>
                      <div class="js-pagination"> <?php echo $this->element('paging_links'); ?> </div>
                  <?php endif; ?>
                <?php echo $form->end();?>
             </div>
    <?php endif; ?>
	 </div>